<?php echo $html->script("onDeleteBlog"); ?>
<div class="users form">
	<h2>My Blogs</h2>
	<table>
		<tr>
			<td class="actions" width="60">
				<?php echo $this->Html->link(__('Add Blog', true), array('controller' => 'blogs', 'action' => 'addBlog')); ?>
			</td>
		</tr>	
	</table>
	
	<?php if($blogs != null){ ?>
	<table>
		<tr>
			<th>Blog Title</th>
			<th>Options</th>
			<?php 
				// ** foreach($blogs as $key => $value) : 
				foreach($blogs as $blog) :
			?>
		</tr>
		<tr>
			<td class="blogTitle" id=<?php echo 'blog_' .$blog['Blog']['id']/*$key*/; ?>> 
				<?php 
					// ** keeping original setup commented
					// ** echo $html->link($value, array('action' => 'viewBlog/' .$key)); 
					echo $html->link($blog['Blog']['subject'], array('action' => 'viewBlog/' .$blog['Blog']['id']));
				?>
			</td>
			<td width="60"><center><?php echo $html->image('edit_icon.png', array('class' => 'blogOptions', 'id' => 'editBlog_' .$blog['Blog']['id']/*$key*/, 
										'width' => '15', 'height' => '15', 'title' => 'Edit Blog')); ?>
				<?php echo $html->image('delete_icon.jpg', array('class' => 'blogOptions', 'id' => 'deleteBlog_' .$blog['Blog']['id']/*$key*/,
						'width' => '15', 'height' => '15', 'title' => 'Delete Blog')); ?>
				</center>
				
				
				
<!-- replacing below links with images to be called through AJAX (images implemented above)
				<?php //echo $html->link('Edit', array('action' => 'editBlog/' .$key. '/' .$user['User']['id']),
					 		//array('class' => 'edit')); ?>      
				<?php	 
					echo $html->link('Delete', array('action' => 'deleteBlog/' .$key), 
							array('class' => 'delete'));
				?> 
-->
				
				
			</td>
		</tr>	
		<?php endforeach; ?>	
	</table>
	
	<?php } else { 
		echo '<b>You currently have no blogs.  Add one!</b>'; 
	} ?>
</div>

	<div class="users form" style="background-color: #EEECF1;">
        <center>
            <?php echo $this->Paginator->prev('<< ' . __('Previous', true), array(), null, array('class' => 'disabled')); ?>
            |
            <?php echo $this->Paginator->numbers(); ?>
            |
            <?php echo $this->Paginator->next(__('Next', true) . ' >>', array(), null, array('class' => 'disabled')); ?>
        </center>
        <br/>
        <center>
            <?php 
            echo $this->Paginator->counter(array(
                'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
            )); 
            ?>
        </center>
    </div>

<div id="popup"></div>



<!-- jquery script that was implemented when learning jquery for the first time
<script>

	$('.edit').bind('click', function(e) {
		//e.preventDefault();
		
		var href = $(this).attr('href');
		//alert(href);
		
		$('#popup').dialog({
			title: "Edit Blog?",
			buttons: [
				{
					text: "Yes",
					click: function() {
						window.location = href;
					}	
				},
				{
					text: "No",
					click: function() {
						$(this).dialog('close');
					}
				}
			]
		});
		
		return false;
	});

	
	$(".delete").bind('click', function() {
		var href = $(this).attr('href');
		
		$('#popup').dialog({
			title: "Are you sure you want to delete this blog?",
			buttons: [
				{
					text: "Yes",
					click: function() {
						window.location = href;
					}
				},
				{
					text: "No",
					click: function() {
						$(this).dialog('close');
					}
				}
			]
			
		});
		
		return false;
	});
</script>
-->
